package com.lxq.blog.com.lxq.blog.service;

import com.lxq.blog.com.lxq.blog.dao.UserDao;
import com.lxq.blog.com.lxq.blog.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class UserService implements UserDetailsService {

    @Autowired
    UserDao userDao;

    public ArrayList<User> findAll(){
        return userDao.findAll();
    }

    public User findByUserName(String userName){
        return userDao.findByUserName(userName);
    }

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return findByUserName(username);
    }
}
